package com.runmi.webchat.aftersale.config;


import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

@javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2017-02-08T09:07:15.712Z")

@Configuration
public class SwaggerDocumentationConfig {

  ApiInfo apiInfo() {
    return new ApiInfoBuilder()
        .title("SCM-API")
        .description("SCM-API")
        .license("")
        .licenseUrl("前台API")
        .termsOfServiceUrl("")
        .version("1.0.0")
        .contact(new Contact("", "", ""))
        .build();
  }

  @Bean
  public Docket customImplementation() {
    return new Docket(DocumentationType.SWAGGER_2)
        .select()
        .apis(RequestHandlerSelectors.basePackage("com.runmi.webchat.aftersale"))
        .build()
        .directModelSubstitute(org.joda.time.LocalDate.class, java.sql.Date.class)
        .directModelSubstitute(org.joda.time.DateTime.class, java.util.Date.class)
        .apiInfo(apiInfo());
  }

//  @Bean
//  Request.Options feignOptions() {
//    return new Request.Options(/**connectTimeoutMillis**/15 * 1000, /** readTimeoutMillis **/15 * 1000);
//  }

  @Bean
  public FilterRegistrationBean registrationBean() {
    FilterRegistrationBean registration = new FilterRegistrationBean();
    registration.setFilter(new ApiOriginFilter());
    registration.addUrlPatterns("/*");
    registration.setOrder(1);
    return registration;
  }

}
